<?php

class maskapai_accounts extends CI_Controller {

    function __construct() {
        parent::__construct();
        if ($this->session->userdata('logged_in')) {
            $session_data = $this->session->userdata('logged_in');
            $data['username'] = $session_data['username'];
        } else {
            redirect('login/costumer', 'refresh');
        }
        $this->load->model('maskapai_account');
        $this->load->model('costumer');
        $this->load->model('berita');
        $this->load->model('rute');
//        $this->load->model('jadwal');
        $this->load->model('airline');
        $this->load->model('deposit');
        $this->load->model('departure');
        $this->load->helper('deposit_helper');
        $this->load->helper('user_helper');
    }

    function index() {
        $id = $this->id();
        $data['id'] = $id;
        $data['news'] = $this->berita->index();
        $data['book_count'] = $this->costumer->book_hitung($id);
        $data['issued_count'] = $this->costumer->issued_hitung($id);
        $data['rows'] = $this->costumer->index($id);
        $data['deposits'] = $this->deposit->index($id);
        $data['options'] = $this->rute->get_array();
        $data['maskapai'] = $this->airline->get_array();
        $data['content'] = 'costumers/index';
//        $this->load->view('template/costumer', $data);
        $this->load->view('template/home1', $data);
    }

    function account() {
        $id = $this->id();
        $data['id'] = $id;
        $data['news'] = $this->berita->index();
        $data['book_count'] = $this->costumer->book_hitung($id);
        $data['issued_count'] = $this->costumer->issued_hitung($id);
        $data['deposits'] = $this->deposit->index($id);
        $data['options'] = $this->rute->get_array();
        $data['maskapai'] = $this->airline->get_array();

        //input

        $id_maskapai = $this->input->post('id_maskapai', TRUE);
        $from = $this->input->post('from', TRUE);
        $to = $this->input->post('to', TRUE);
        $date = $this->input->post('date', TRUE);
        $pulang = $this->input->post('pulang', TRUE);
        $price = $this->input->post('price', TRUE);
        $adult = $this->input->post('adult_post', TRUE);
        $child = $this->input->post('child_post', TRUE);
        $infant = $this->input->post('infant_post', TRUE);
        
        
        $deposit = get_total($this->deposit->index($id));
        if ($deposit < $price) {
            $data['price'] = $price;
            $data['content'] = 'maskapai_accounts/deposit';
//        $this->load->view('template/costumer', $data);
            $this->load->view('template/home1', $data);
        }else{
        //

        $data['rows'] = $this->maskapai_account->show($id_maskapai);




        $data['content'] = 'maskapai_accounts/show';
//        $this->load->view('template/costumer', $data);
        $this->load->view('template/home1', $data);
        }
    }

    function id() {
        $session_data = $this->session->userdata('logged_in');
        return $session_data['id'];
    }

}

?>
